﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Microsoft.DirectX.Direct3D;

namespace SnakeX
{
	/// <summary>
	/// This class represents a Direct3D device.
	/// </summary>
	public class SnakeXDevice
	{

		/// <summary>
		/// Initializing Driect3D device.
		/// </summary>
		/// 
		/// <param name="form">
		/// The form instance to use the Direct3D device on.
		/// </param>
		/// <param name="windowed">
		/// Whether the program will run in windowed mode or not.
		/// </param>
		public SnakeXDevice(Control form, bool windowed)
		{
			// Setting present parameters.
			PresentParameters presentParams = new PresentParameters();
			presentParams.Windowed = windowed; // Window or full-screen.
			presentParams.SwapEffect = SwapEffect.Discard; // Swapping effects.

			// Initializing direct3d device.
			d3dDevice = new Device(0, DeviceType.Hardware, form,
				CreateFlags.HardwareVertexProcessing, presentParams);

			// Setting device vertex format.
			d3dDevice.VertexFormat = CustomVertex.TransformedColored.Format;
		}



		/// <summary>
		/// Direct3D device instance.
		/// </summary>
		private Device d3dDevice = null;

		public Device D3dDevice
		{
			get 
			{
				return d3dDevice; 
			}
		}
	}



}
